package demo2;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class Main4 {
    public static void main(String[] args) {
        ThreadPoolExecutor threadPoolExecutor=new ThreadPoolExecutor(5,10,1,
                TimeUnit.SECONDS,new LinkedBlockingQueue<>(5),new ThreadPoolExecutor.CallerRunsPolicy());
        for (int i = 0; i <100 ; i++) {
            int temp=i+1;
            threadPoolExecutor.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(temp+"   "+Thread.currentThread().getName());
                }
            });
        }
    }
}
